<template>
  <div>
    <div class="pinglun">
      <div class="authorinfo">
        <div class="left">
          <img :src="item.aut_photo" alt style="width:25px;height:25px;border-radius: 50%;" />
          <span class="info">
            <span class="name">{{item.aut_name}}</span>
            <span class="cont">{{item.content}}</span>
            <span class="time">
              <span>{{item.pubdate | format}}</span>
              <van-button round type="default" @click="reply(item)">回复{{item.reply_count}}</van-button>
            </span>
          </span>
        </div>
        <div class="right">
          <van-icon
            slot="icon"
            :name="item.is_liking?'good-job':'good-job-o'"
            :class="{active:item.is_liking}"
            style="font-size:14px;"
            @click="likeFunc(item.is_liking,item.com_id)"
          />
          <span style="font-size:11px;margin-left:5px">赞</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import {
  commentliking_api,
  nocommentliking_api,
  //   getRecomments_api,
} from "@/api/user.js";
import { Form } from "vant";
export default {
  props: {
    item: {
      type: [Array, Object, String, Number],
    },
  },
  data() {
    return {
      show: false,
      replyList: [],
    };
  },
  methods: {
    // 点赞
    async likeFunc(liking, id) {
      if (!liking) {
        // liking = !liking;
        // 点赞
        const { data: res } = await commentliking_api(id);
        this.$toast("点赞成功");
      } else {
        // 不点赞
        const { data: res } = await nocommentliking_api(id);
        this.$toast("取消点赞");
      }
      liking = !liking;
    },
    // 回复
    reply(item) {
      this.$emit("comment-reply", item);
    },
  },
  components: {},
};
</script>
<style lang='less' scoped>
.active {
  color: #e5645f;
}
.authorinfo {
  height: 120px;
  display: flex;
  justify-content: space-between;
  padding: 20px 0;
  .left {
    display: flex;
    img {
      vertical-align: middle;
      margin-right: 20px;
    }
    .name {
      color: #6bb4eb;
    }
    .info {
      font-size: 24px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }
  }
  .van-button {
    margin-left: 20px;
    width: 150px;
    height: 50px;
    .van-button__text {
      font-size: 12px;
      color: #000;
    }
  }
}
</style>